<?php
/*  
  Copyright (c) 2010-02 SongCMS 
  SongCMS All Rights Reserved. 
  Support:www.SongCMS.com
  QQ:544255858   19951025
  Author:Song  Version:3.17
  Date:2010-08-12 09:28:32
*/

include_once('Admin.php'); include_once('../config/slideshow.php');
$slide = $slide[$Lang];
$xCount = is_numeric($_GET['nu']) ? $_GET['nu'] : count($slide['title']);

if($_POST['Action'] == 'UpDate'){
	$oFile = '../config/slideshow.php';
	
	$ncz = true;
	$up = new upload();
	$up->ispics = true;
	$up->save_dir = '../uploadfile/Media/';	
	$up->save_son_dir = false;

	for($i=0; $i<$xCount; $i++){
		if(!empty($_FILES["smallimage{$i}"]['tmp_name'])){
			$up->field_name = "smallimage{$i}";
			$up->new_filename = "focus_small_{$Lang}_".($i+1);
			if($up->perform()){
				$smallimage[$i] = str_replace('../','',$up->URL);	
			} else {
				$smallimage[$i] = $slide['previews'][$i];
				$ncz = $up->info; //捕获失败的上传信息
			}			
		} else {
			$smallimage[$i] = $slide['previews'][$i];
		}

		if(!empty($_FILES["image{$i}"]['tmp_name'])){
			$up->field_name = "image{$i}";
			$up->new_filename = "focus_max_{$Lang}_".($i+1);
			if($up->perform()){
				$image[$i] = str_replace('../','',$up->URL);	
			} else {
				$image[$i] = $slide['picture'][$i];
				$ncz = $up->info; //捕获失败的上传信息
			}			
		} else {
			$image[$i] = $slide['picture'][$i];
		}
	}
	
	$oVar['na'] = array("slide\[{$Lang}\]\[\'title\'\]","slide\[{$Lang}\]\[\'previews\'\]","slide\[{$Lang}\]\[\'picture\'\]","slide\[{$Lang}\]\[\'link\'\]","slide\[{$Lang}\]\[\'concise\'\]");
	@$oVar['va'] = array(implode('|',$_POST['headline']),implode('|',$smallimage),implode('|',$image),implode('|',$_POST['video']),implode('|',$_POST['caption']));
	if(($fnc = $admin->updatevar($oFile,$oVar)) === true){
		AdminLog(1,1,'修改幻灯片设置，结果：操作成功！');
		if($ncz !== true) MsgBox (1,'数据修改成功，有部分图片未能上传，返回上传信息：'.$ncz,'1');
		MsgBox (1,'幻灯片修改成功！',"SlideManage.php?Lang={$Lang}&nu={$_GET['nu']}&".time());
	} else {
		AdminLog(1,1,'修改幻灯片设置失败，返回信息：' . $fnc);
		MsgBox (1,$fnc,"1");
	}	
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="./images/adminstyle.css" rel="stylesheet" type="text/css" />
<link href="../tools/highslide/highslide.css" rel="stylesheet" type="text/css" />
<link rel="Shortcut Icon" href="../favicon.ico">
<link rel="Bookmark" href="../favicon.ico">
<script src="../js/csshovernotie6.js" type="text/javascript"></script>
<script src="../tools/highslide/highslide.js" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
hs.graphicsDir = '../tools/highslide/graphics/';
hs.showCredits = false;
hs.outlineType = 'rounded-white';
hs.restoreTitle = '关闭';
</script>
<style type="text/css">
.jq{border-bottom:1px #000 solid;}
.jqb{font-family:Verdana, Geneva, sans-serif; font-size:16px; font-weight:bold; border-bottom:1px #000 solid; font-style:italic; color:#066;}
</style>
</head>
<body>
<br />
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr class="Notodd"><td><?php TopLang();?></td><td align="right">
		设置焦点图数量：
		<select OnChange="window.open(this.options[this.selectedIndex].value,'_self')" size="1">
		<?php
		for ($i=1; $i<=20; $i++ ) {
			if($i != $xCount){
				echo '<option value="SlideManage.php?Lang=' . $Lang . '&nu=' . $i . '">' . $i . '</option>' . "\n";
			}else{
				echo '<option selected="selected" value="SlideManage.php?Lang=' . $Lang . '&nu=' . $i . '">' . $i . '</option>' . "\n";
			}
		}
		?>  	
		</select>		
	</td></tr>
</table>
<table width="98%" border="0" align="center" cellpadding="4" cellspacing="1" bgcolor="#CCCCCC">
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <tr>
    <td colspan="4" align="center" class="Main_Title">焦点图管理<?php echo $OnWebLangName?></td>
  </tr>
<?php
$rowspan = 3+$Focus['preview']+$Focus['introdu']; //序号合并单元格
for ($i=0; $i<$xCount; $i++){
?>  
  <tr class="odd">
  	<td rowspan="<?php echo $rowspan;?>" align="center" class="jqb"><?php echo ($i+1)?></td>
    <td height="20" align="right">标题文字：</td>
    <td><input name="headline[]" type="text" value="<?php echo $slide['title'][$i]?>" class="input2" /></td>
    <td>视模板而定，部分焦点图效果可能没有用到该字段</td>
  </tr>
  <?php if($Focus['preview']==1){?><tr class="odd">
  	<td height="20" align="right">预览小图：</td>
  	<td><input name="smallimage<?php echo $i?>" id="smallimage<?php echo $i?>" type="file" size="35" /></td>
  	<td>
<?php
$npics = "../{$slide['previews'][$i]}";
if(is_file($npics)){
	echo "<a href=\"{$npics}\" onclick=\"return hs.expand(this);\"><img border=\"0\" height=\"45\" src=\"{$npics}\" /></a>";
} else {
	echo '请上传图片';
}
?>	
</td>
  	</tr><?php }?>
  <tr class="odd">
  	<td height="20" align="right">焦点图片：</td>
  	<td><input name="image<?php echo $i?>" id="image<?php echo $i?>" type="file" size="35" /></td>
  	<td>
<?php
$xpics = "../{$slide['picture'][$i]}";
if(is_file($xpics)){
	echo "<a href=\"{$xpics}\" onclick=\"return hs.expand(this);\"><img border=\"0\" height=\"45\" src=\"{$xpics}\" /></a>";
} else {
	echo '请上传图片';
}
?></td>
  	</tr>
  <?php if($Focus['introdu']==1){?><tr class="odd">
  	<td height="20" align="right">简要介绍：</td>
  	<td><textarea name="caption[]" cols="40" rows="4"><?php echo $slide['concise'][$i]?></textarea></td>
  	<td>&nbsp;</td>
  	</tr><?php }?>
  <tr class="odd">
  	<td height="20" align="right" class="jq">链接地址：</td>
  	<td class="jq"><input name="video[]" type="text" value="<?php echo $slide['link'][$i]?>" class="input2" /></td>
  	<td class="jq">一般指图片或标题的链接地址</td>
  	</tr>
<?php }?>	
  <tr class="odd">
  	<td align="right" height="30">&nbsp;</td>
  	<td height="20" align="right">&nbsp;</td>
  	<td><input type="submit" name="button" id="button" value="提 交" class="submit" /><input name="Action" type="hidden" value="UpDate" /></td>
  	<td>&nbsp;</td>
  	</tr>
	</form>
  </table>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="6">
	<tr class="Notodd">
		<td style="color:#333333; line-height:20px;">
注：1、请根据不同的焦点图效果，设置当前模板支持的最佳规格图片，图片数量、规格等参数视不同的模板而定；<br />
　　2、不更换图片时不用上传,上传将会替换当前图片；<br />
　　3、系统不对焦点图进行裁切和加水印处理，请上传修改好的图片。
		</td>
	</tr>
</table>  
</body>
</html>